import static junit.framework.Assert.assertTrue;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;

/**
 * Tests input for the gui
 *
 * @author Arun Lee, Michael Terada, Marek Lopez
 */
public class testGui extends TestCase {

    private ics314ui gui;

    public testGui(String name) {
        super(name);
    }

    @Before
    public void setUp() throws Exception {
        gui = new ics314ui();
        gui.init();
    }

    /**
     * Verify that latitude and longitude are within their valid range
     */
    @Test
    public void testInput() {
        int lat;
        int lon;
        String date = "2013/04/27";
        lat = (int) (Math.random() * 300);
        lon = (int) (Math.random() * 300);
        if (Math.random() > .5) {
            lat *= -1;
        }

        if (Math.random() > .5) {
            lon *= -1;
        }

        gui.setTestValues(lat, lon, date);
        gui.testValidate();
        assertTrue("value test for latitude and longitude", (gui.getLatitude() <= 90 && gui.getLatitude() >= -90));
        assertTrue("value test for latitude and longitude", (gui.getLongitude() <= 180 && gui.getLongitude() >= -180));
    }

    /**
     * Verifies that our clear button works and sets inputs to 0 or null
     */
    @Test
    public void testClear() {
        gui.clear();
        assertTrue(gui.getLatitude() == 0);
        assertTrue(gui.getLongitude() == 0);
        assertTrue(gui.drawF == null);
        assertTrue(gui.drawG == null);
    }
}
